fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <cmath>
  4. #include <stdio.h>
  5. #include <cstring>
  6. #include <map>
  7. #include <algorithm>
  8. using namespace std;
  9.  
  10.  
  11. bool all_arr[21]={1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};
  12. bool clear_arr[21]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
  13. bool arr[21];
  14. long long M;
  15. string asd;
  16. int x;
  17. vector <bool> result;
  18. int result_cnt;
  19.  
  20. int main()
  21. {
  22. ios_base::sync_with_stdio(0);
  23. cin.tie(0);
  24.  
  25. cin>>M;
  26. for(int i=0; i<M; i++)
  27. {
  28. cin>>asd;
  29.  
  30. if(asd=="add")
  31. {
  32. cin>>x;
  33. arr[x] = true;
  34. }
  35. else if(asd=="remove")
  36. {
  37. cin>>x;
  38. arr[x] = false;
  39. }
  40. else if(asd=="toggle")
  41. {
  42. cin>>x;
  43. arr[x] = ~arr[x];
  44. }
  45. else if(asd=="all")
  46. {
  47. for(int i=1; i<21; i++)
  48. {
  49. arr[i] = true;
  50. }
  51. }
  52. else if(asd=="empty")
  53. {
  54. for(int i=1; i<21; i++)
  55. {
  56. arr[i] = false;
  57. }
  58. }
  59. else if(asd=="check")
  60. {
  61. cin>>x;
  62. if(arr[x])
  63. {
  64. result.push_back(true);
  65. result_cnt++;
  66. }
  67. else
  68. {
  69. result.push_back(false);
  70. result_cnt++;
  71. }
  72.  
  73. }
  74.  
  75. }
  76.  
  77. for(int i=0; i<result_cnt; i++)
  78. {
  79. cout<<result[i]<<"\n";
  80. }
  81.  
  82. return 0;
  83. }
Success #stdin #stdout 0s 5300KB
stdin
26
add 1
add 2
check 1
check 2
check 3
remove 2
check 1
check 2
toggle 3
check 1
check 2
check 3
check 4
all
check 10
check 20
toggle 10
remove 20
check 10
check 20
empty
check 1
toggle 1
check 1
toggle 1
check 1
stdout
1
1
0
1
0
1
0
1
0
1
1
1
0
0
1
1